// Copyright (c) 2009 Luca Marrocco.
// Modified or written by Luca Marrocco for inclusion with codej.
// Licensed under the Apache License, Version 2.0 (the "License")
package codej.ast;

import static codej.ast.Option.*;

import java.util.*;

import codej.ast.*;

/** @author Luca Marrocco */
public class VariableDeclaration extends VariableDeclarator {

	private List<Annotation> annotations = new LinkedList<Annotation>();
	private boolean isFinal = false;
	private Type type;
	boolean isFormalParameter;
	private VariableDeclarators variableDeclarators;

	public VariableDeclaration() {
	}

	public void accept(Visitor visitor) {
		visitor.visit(this);
	}

	public VariableDeclaration addAnnotation(Annotation annotation) {
		annotations.add(annotation);
		return this;
	}

	public VariableDeclaration addModifier(Modifier modifier) {
		addChild(modifier);
		return this;
	}

	public VariableDeclaration addVariableDeclarator(VariableDeclarator variableDeclarator) {
		addChild(variableDeclarator);
		return this;
	}

	public List<Annotation> getAnnotations() {
		return annotations;
	}

	public boolean getFinal() {
		return isFinal;
	}

	public boolean getFormalParameter() {
		return isFormalParameter;
	}

	public Type getType() {
		return type;
	}

	public boolean isFinal() {
		return isFinal;
	}

	public boolean isFormalParameter() {
		return isFormalParameter;
	}

	public VariableDeclaration setFinal(boolean isFinal) {
		this.isFinal = isFinal;

		return this;
	}

	public VariableDeclaration setFormalParameter(boolean isFormalParameter) {
		this.isFormalParameter = isFormalParameter;
		return this;
	}

	public VariableDeclaration setType(Type type) {
		this.type = type;

		return this;
	}

	public void setVariableDeclarators(VariableDeclarators variableDeclarators) {
		this.variableDeclarators = variableDeclarators;
	}

	public VariableDeclarators getVariableDeclarators() {
		return option(variableDeclarators, new VariableDeclarators());
	}
}